#!/usr/bin/env bash

#去掉master污点 防止调度器调度当前master
kubectl taint nodes `hostname` node-role.kubernetes.io/master:NoSchedule- 2>/dev/null
kubectl taint nodes `hostname` node.kubernetes.io/not-ready:NoSchedule- 2>/dev/null

kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/v0.20.2/Documentation/kube-flannel.yml

kubectl get all -n kube-flannel

while true
do
    kubectl get pods -n kube-flannel|grep -q '0/1'
    if [ $? -ne 0 ];then
        echo "flannel started"
        break
    else
        echo "flannel starting...."
    fi
    sleep 1
done
